<template lang="html">
  <div  >
      <div class="bt">
        <el-button type="primary" @click="confirm('post')" :disabled="disableda">保存</el-button>
        <!-- <el-button v-if="this.$route.query.id != ''" type="primary" @click="confirm('post')" :disabled="disableda">更新</el-button> -->

      </div>
      <div class="ww" v-loading="loading2">
        <EditorVue v-model="article.content"/>
            <!-- <div class="quill">
              <quill-editor
                  v-model="ruleForm.detailContent"
                  ref="myQuillEditor">
              </quill-editor>
            </div> -->
      </div>
  </div>
</template>

<script>

import {
  addText,
  textDetails
} from "@/api/shoppingCentre/productCentre";
import EditorVue from '@/components/Editor.vue'
export default {
  components : {
    EditorVue,
  },
  data () {
    return {
      article : {
          content :'',
      },
      loading2 : false,
      disableda : false,
      rules : {

      }
    }
  },
  mounted () {
     if (this.$store.state.category.goodsId == '') {
       this.$store.state.category.idx = '2'
       return false
     }
      if (this.$store.state.category.goodsId) {
         this.loading2 = true;
          textDetails(this.$store.state.category.goodsId).then(res=>{
            if (res.data.code =='OK') {
               if (res.data.data != null) {
                  this.article.content = res.data.data.context;
               }
              setTimeout(()=>{
                  this.loading2 = false
              },2000)
            } else {
              this.loading2 = false
            }
          })
      }
  },
  methods : {
    confirm (method) {
      // this.disableda = true;
      var data = {
        context : this.article.content,
        goodsId : this.$store.state.category.goodsId
      }
      addText(data,method).then(res=>{
         if (res.data.code == 'OK') {
            if (method == 'post') {
              this.$message.success('发布成功');
            }
         } else {
           this.$message.error(res.data.message);
            this.disableda = false;
         }
      })
    }
  }
}
</script>

<style scoped>
  .bt {
    margin-top: 20px;
  }
  .ww {
    background: #ffff;
    padding: 33px;
    margin-top: 20px;
  }
  .el-form {
    width: 349px;

  }
</style>
